import json

import requests
import random
import hashlib

# urls = [f'http://httpbin.org/get?value={random.randint(1,10)}' for i in range(10)]
# done_url = set()
#
# for url in urls:
#     if url not in done_url:
#         done_url.add(url)
#         response = requests.get(url)
#         print(response.json())
#     else:
#         print('已经请求过了')


url = 'http://httpbin.org/post'
datas = [{'id': 101, 'value': random.randint(1, 10)} for i in range(10)]
requested_data = set()
for data in datas:
    hash_data = hashlib.md5(json.dumps(data).encode('utf-8')).hexdigest()
    if hash_data not in requested_data:
        requested_data.add(hash_data)
        response = requests.post(url, data=data)
        print(response.json())
    else:
        print('已经请求过了')